import { http } from "../http";
const baseUrl = "/api/evaluateTask";

export interface ExpertType {
  id: string;
  userName: string;
  userCode: string;
}

export interface EvaluateTaskType {
  id: string;
  name: string;
  desc?: string | null | undefined;
  resourceType: string;
  resourceId: string;
  resourceName: string;
  templateId: string;
  templateName: string;
  execStatus: number;
  planDuration: number;
  expertList: ExpertType[];
  segmentTime: number;
  createTime: string;
  updateTime: string;
  startTime?: string;
  endTime?: string;
  realDuration?: number; // 已经进行的时长（秒）
  lastStartTime?: string; // 最近一次开始的时间点
}

export type GetevaluateTaskListQueryType = {
  name?: string;
  execStatus?: number;
  resourceName?: string;
  expertIds?: string[];
  startTime?: string;
  endTime?: string;
  currentPage?: number;
  numPerPage?: number;
  minScore?: number | null;
  maxScore?: number | null;
};

export interface GetevaluateTaskListResponseType {
  list: EvaluateTaskType[];
  currentPage: number;
  numPerPage: number;
  totalCount: number;
}

export interface AddOrUpdateEvaluateTaskQueryType {
  id?: string;
  name: string;
  desc?: string | null | undefined;
  resourceType: string;
  resourceId: string;
  resourceName: string;
  templateId: string;
  templateName: string;
  execStatus: number;
  planDuration: number;
  expertIds: string[];
  segmentTime: number;
  createTime?: string;
  updateTime?: string;
}

export interface EndEvaluateTaskQueryType {
  evaluateTaskId: string;
  execStatus: number;
}

export interface UpdateEvaluateTaskStatusQueryType {
  evaluateTaskId: string;
  time: string;
  execStatus: number;
}

// 获取评价任务列表
export const getevaluateTaskListAPI = (
  params: GetevaluateTaskListQueryType
) => {
  return http.post(`${baseUrl}/getEvaluateTaskList`, params);
};

// 开始评价任务
export const addOrUpdateEvaluateTaskAPI = (
  params: AddOrUpdateEvaluateTaskQueryType
) => {
  return http.post(`${baseUrl}/addOrUpdateEvaluateTask`, params);
};

// 更新评价任务状态
export const updateEvaluateTaskStatusAPI = (
  params: UpdateEvaluateTaskStatusQueryType
) => {
  return http.post(`${baseUrl}/updateEvaluateTaskStatus`, params);
};

// 获取评价任务详情
export const getevaluateTaskDetailAPI = (params: {
  evaluateTaskId: string;
}) => {
  return http.post(`${baseUrl}/getEvaluateTaskDetail`, params);
};
